﻿#if false
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;

namespace ArgUrTMapManager
{
	static class Constants
	{
#if DEBUG
		//public const string GameDir = @"C:\Games\Urban Terror Server";
		public const string GameDir = @"C:\Games\World of Padman";
#else
		public static readonly string GameDir = System.Environment.CurrentDirectory;
#endif
		//public static readonly string GameDataDir = Path.Combine(Constants.GameDir, "q3ut4");
		public static string[] GameDataDirectories { get; private set; }
		//public static readonly string GameBinary = Path.Combine(Constants.GameDir, "Quake3-UrT.exe");
		//public static readonly string GameServerBinary = Path.Combine(Constants.GameDir, "Quake3-UrT-Ded.exe");
		public const string ServerConfigFile = "server.cfg"; // The Game expects this File to be in Constants.GameDataDir
		public const string PackageFileExt = ".pk3";
		public const string MapFileExt = ".bsp";
		public const string BotMapFileExt = ".aas";
		//public const string LevelshotFileExt = ".jpg";
		public const string TextureFileExt = ".jpg";
		public const string TextureFileExt2 = ".tga";
		public const string ShaderscriptFileExt = ".shader";
		public const string ZipMaps = "maps/";
		public const string ZipLevelshots = "levelshots/";
		public const string ZipScripts = "scripts/";
		public const string ZipTextures = "textures/";
		public const string LevelshotUnkownMap = "menu/art/unknownmap.jpg";
		public static readonly string[] ShaderTextureKeywords = new string[] { "qer_editorimage", "map", "q3map_lightimage", "clampmap" };

		public const string CommandMap = "map";
		public const string CommandExec = "exec";
		public const string CommandSet = "set";

		public const string CVarMapCycleFile = "g_mapcycle";
		public static string AppDataQuakeLive { get; private set; }

		public static void Initialize()
		{
			string[] dirs = Directory.GetDirectories(Constants.GameDir);
			List<string> GameDataDirs = new List<string>();
			foreach (string dir in dirs)
			{
				string[] paks = Directory.GetFiles(dir, "*" + FileExtensions.Packages);
				if (paks.Length > 0)
				{
					GameDataDirs.Add(dir);
				}
			}

			string virtualstore = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VirtualStore");
			string gameDir = Constants.GameDir.Substring(Path.GetPathRoot(Constants.GameDir).Length);
			gameDir = Path.Combine(virtualstore, gameDir);
			if (Directory.Exists(gameDir) == true)
			{
				dirs = Directory.GetDirectories(gameDir);
				foreach (string dir in dirs)
				{
					string[] paks = Directory.GetFiles(dir, "*" + FileExtensions.Packages);
					if (paks.Length > 0)
					{
						GameDataDirs.Add(dir);
					}
				}
			}

			if (GameDataDirs.Count < 1)
				GameDataDirs.Add(Constants.GameDir);
			Constants.GameDataDirectories = GameDataDirs.ToArray();

			Constants.AppDataQuakeLive = Path.Combine(Constants.GetKnownFolderPath(KnownFolderId.LocalAppDataLow), @"id Software\quakelive\baseq3");
		}

		public static readonly byte[] QuakeLiveXorKey = new byte[]
			{
				0xcf, 0x8e, 0x8e, 0x4c, 0xd0, 0xd9, 0x30, 0xce, 0x07, 0x32,
				0x27, 0x64, 0xed, 0x16, 0x06, 0x12, 0x20, 0x99, 0x55, 0x21,
				0x7b, 0x10, 0xef, 0x57, 0x8b, 0xbf, 0x2e, 0x09, 0xee, 0x6b,
				0xaa, 0x7c, 0xcc, 0x3c, 0x95, 0xee, 0xba, 0xd7, 0x4b, 0x88,
				0x84, 0x88, 0xd2, 0x70, 0x4c, 0x09, 0x30, 0xf2, 0xaf, 0xb0,
				0x99, 0x0d, 0x1f, 0x5f, 0xa7, 0xc5, 0xaf, 0x61, 0xc1, 0x18,
				0xed, 0x16, 0xb0, 0x32, 0xf5, 0x07, 0x2f, 0x72, 0xb1, 0x23,
				0x66, 0x1f, 0xf5, 0x18, 0xef, 0xb3, 0x9d, 0xf0, 0x4a, 0x02,
				0x8f, 0x37, 0xff, 0xb0, 0xd7, 0xaf, 0xd3, 0x09, 0xb4, 0x4a,
				0x2c, 0x63, 0xa3, 0x24, 0x1e, 0x52, 0xdf, 0x12, 0x9c, 0x8e,
				0xff, 0x31, 0x2f, 0x0e, 0x48, 0xfa, 0x25, 0xc5, 0x43, 0xe4,
				0x71, 0x69, 0xf4, 0x84, 0x91, 0x84, 0x0c, 0xc2, 0x3f, 0x7d,
				0xb0, 0xe1, 0xe6, 0x03, 0x36, 0xbb, 0xed, 0x22, 0x89, 0xe9,
				0x81, 0x6c, 0x4e, 0xfb, 0x41, 0x84, 0xba, 0xf1, 0x5b, 0x1e,
				0xbf, 0x30, 0xbf, 0x77, 0x0e, 0x47, 0x1c, 0x84, 0xe9, 0xa0,
				0x9e, 0x5b, 0x35, 0xa7, 0xee, 0x3c, 0x40, 0x0d, 0xb9, 0x70,
				0x2a, 0x11, 0xf8, 0xc9, 0x41, 0x33, 0x89, 0x9c, 0x51, 0xf2,
				0x40, 0xf0, 0xe5, 0xe8, 0xd7, 0x1e, 0x77, 0xde, 0x19, 0x46,
				0x00, 0x57, 0xf0, 0x02, 0x5c, 0x1d, 0x64, 0xb9, 0x40, 0xc8,
				0x1a, 0x99, 0x5f, 0xa7, 0x4d, 0x5a, 0x72, 0x3e, 0x80, 0xc3,
				0xa1, 0x1a, 0x6e, 0x1e, 0xd0, 0x79, 0x06, 0x6b, 0xee, 0x50,
				0x76, 0x81, 0x71, 0xa4, 0xb1, 0xdb, 0xab, 0x40, 0x1a, 0xa7,
				0x8a, 0xee, 0x06, 0xb9, 0xf2, 0x22, 0x13, 0x30, 0x43, 0x19,
				0xe1, 0xe3, 0x34, 0xce, 0x1e, 0x03, 0x1a, 0x04, 0xe7, 0xa4,
				0x4a, 0xc7, 0x6a, 0x8e, 0x6f, 0xad, 0x7f, 0x3d, 0x89, 0x11,
				0x97, 0xad, 0x95, 0x20, 0xe8, 0x35, 0xc7, 0xd1, 0x02, 0x00,
				0x0a, 0xe5, 0x81, 0x25, 0x91, 0x2c, 0xa2, 0x87, 0x16, 0xc3,
				0xcc, 0xc9, 0x1f, 0x6d, 0x56, 0x64, 0x82, 0xd6, 0x69, 0x97,
				0x7d, 0xcb, 0x58, 0x40, 0xd0, 0x00, 0x16, 0xc3, 0xee, 0xb7,
				0x19, 0xd6, 0x06, 0x6f, 0x39, 0x7b, 0x60, 0xba, 0x7b, 0xef,
				0xfb, 0xc0, 0x79, 0x3c, 0xe7, 0x0b, 0x6f, 0x67, 0x36, 0xaf,
				0xa9, 0x3a, 0x3f, 0xc2, 0x31, 0x72, 0x09, 0xa3, 0xfd, 0x4e,
				0xc8, 0x52, 0x96, 0xda, 0x67, 0xf1, 0xb9, 0x79, 0xa9, 0xcc,
				0xd3, 0x6f, 0xe7, 0xf6, 0xa0, 0x80, 0x0f, 0xcf, 0x7c, 0xb5,
				0x9a, 0x89, 0xe6, 0xfa, 0xd3, 0xec, 0xc9, 0xf5, 0xcc, 0x53,
				0x65, 0x73, 0x05, 0xd3, 0xd7, 0x83, 0x56, 0x84, 0x68, 0x94,
				0xa3, 0x52, 0x1a, 0x0a, 0xcb, 0xe7, 0xcf, 0xed, 0x22, 0xfe,
				0xd6, 0x3c, 0xf7, 0x84, 0x03, 0xbf, 0xeb, 0x77, 0x82, 0x5b,
				0x8a, 0x35, 0x67, 0x2b, 0x97, 0x75, 0x5a, 0x81, 0xc9, 0x37,
				0x6b, 0xe3, 0x77, 0x4f, 0x82, 0x5c, 0x75, 0x3f, 0xc3, 0xa1,
				0x84, 0xe4, 0x2c, 0x43, 0x33, 0x8b, 0xec, 0xd6, 0x32, 0xf2,
				0xfa, 0x3a, 0x65, 0x06, 0xb7, 0x51, 0x88, 0x85, 0x5b, 0xab,
				0x0f, 0x36, 0x41, 0xc5, 0x2f, 0x6d, 0x34, 0x31, 0x70, 0x59,
				0xb5, 0x2e, 0x44, 0x31, 0x62, 0xb9, 0x38, 0x39, 0xf7, 0xb6,
				0x6e, 0xcf, 0xf2, 0x7f, 0x78, 0xdd, 0xf0, 0x8e, 0xc4, 0x23,
				0x5a, 0x48, 0xd0, 0xa5, 0xa8, 0x90, 0x69, 0xa9, 0x53, 0xec,
				0x45, 0xd6, 0x97, 0x9b, 0x92, 0x3e, 0x0a, 0x50, 0x90, 0x3f,
				0xe9, 0x92, 0xdc, 0x85, 0xaa, 0xab, 0x57, 0xa7, 0x0e, 0xe8,
				0xff, 0xcf, 0xfc, 0x4d, 0x9a, 0xc6, 0x36, 0xe3, 0x5a, 0x0d,
				0x83, 0x12, 0xc5, 0x84, 0x85, 0x8a, 0x74, 0xcf, 0x42, 0x33,
				0x8c, 0xeb, 0xd3, 0x49, 0x4d, 0x60, 0x15, 0xbe, 0xad, 0x73,
				0x92, 0x37, 0x29, 0x3e, 0x63, 0x83, 0x1f, 0xd1, 0xc6, 0x9a,
				0xbc, 0xb8, 0xc6, 0xac, 0x34, 0x34, 0x87, 0xd2, 0xe7, 0x0b,
				0x77, 0xf9, 0x2f, 0x52, 0x37, 0xbb, 0x10, 0xa8, 0xe1, 0xde,
				0x33, 0xf2, 0x52, 0x2e, 0xe5, 0x56, 0x7e, 0xff, 0x5c, 0xec,
				0x82, 0x50, 0xe1, 0xb0, 0x4e, 0xa1, 0x23, 0x86, 0x08, 0x22,
				0xa6, 0x56, 0x2b, 0x40, 0x99, 0xf4, 0x8e, 0x3d, 0xe2, 0x10,
				0x05, 0xf1, 0xdd, 0x21, 0x69, 0x77, 0x07, 0x59, 0x90, 0x2f,
				0xf1, 0xbb, 0xb8, 0x03, 0x5a, 0x21, 0xe1, 0xe5, 0x0c, 0xaa,
				0x52, 0xda, 0xa1, 0x73, 0x31, 0x18, 0x12, 0xb2, 0x85, 0x52,
				0x07, 0xf6, 0x8f, 0x23, 0xb0, 0xf7, 0x4a, 0x9a, 0x6f, 0x0a,
				0x6c, 0x1f, 0xbe, 0x3f, 0x88, 0xad, 0xe9, 0x55, 0x4a, 0xb7,
				0x44, 0xfb, 0xf8, 0x25, 0x6a, 0x2a, 0xf1, 0xd9, 0xfe, 0xb8,
				0x62, 0xc5, 0xae, 0xed, 0x5c, 0x8b, 0x0f, 0x4b, 0x8a, 0xfe,
				0x01, 0x68, 0x8b, 0xe1, 0x3f, 0x84, 0x3c, 0x6f, 0x10, 0xbf,
				0xb5, 0x0f, 0x82, 0x41, 0x97, 0x39, 0x64, 0x18, 0x3d, 0xef,
				0xa4, 0x3a, 0x5f, 0x33, 0x9d, 0x4b, 0x6e, 0xa3, 0x77, 0x97,
				0x06, 0xfb, 0x1b, 0x8f, 0xf0, 0xed, 0xe3, 0x84, 0x1b, 0x73,
				0x51, 0x72, 0x0b, 0x2d, 0xf1, 0x78, 0x59, 0xd9, 0x16, 0x50,
				0x97, 0x1b, 0xe0, 0x5d, 0x27, 0xc3, 0xbb, 0x77, 0x2e, 0x15,
				0xd2, 0xd2, 0x33, 0x68, 0xee, 0xd8, 0x0f, 0x28, 0xf5, 0x0c,
				0x1b, 0x98, 0x1b, 0xda, 0x1d, 0x75, 0xc4, 0x2b, 0xb8, 0x45,
				0x8b, 0xc0, 0x6e, 0x88, 0x88, 0xad, 0x61, 0xf8, 0x09, 0x1c,
				0xb1, 0x46, 0xeb, 0xbb, 0xa2, 0xf5, 0xbc, 0x5c, 0x7b, 0x02,
				0xdb, 0xcc, 0xad, 0x97, 0x1c, 0x5b, 0xa9, 0x97, 0x0e, 0x49,
				0xea, 0x6d, 0x13, 0xba, 0x6f, 0x11, 0xcf, 0x2c, 0x2f, 0xc7,
				0x9b, 0xb4, 0x80, 0x49, 0x18, 0x9e, 0x4c, 0x94, 0x5a, 0x55,
				0x06, 0x4d, 0x42, 0x75, 0xb6, 0xa2, 0x61, 0xdb, 0xfa, 0x41,
				0xca, 0x92, 0x70, 0xcc, 0x7e, 0x52, 0x66, 0x01, 0x13, 0x53,
				0xef, 0xae, 0x40, 0xbd, 0xb7, 0xb6, 0xf2, 0xc7, 0xdd, 0x28,
				0xb1, 0x11, 0xd4, 0x78, 0x79, 0xc2, 0x22, 0xbf, 0x29, 0xa0,
				0x3a, 0x83, 0xc5, 0x76, 0x17, 0xe6, 0x94, 0x1e, 0xee, 0x63,
				0xd2, 0x1e, 0x52, 0xfd, 0x24, 0x9f, 0x40, 0xa7, 0x0c, 0x0a,
				0xe7, 0xeb, 0x9d, 0x12, 0x2a, 0xf3, 0xe3, 0x5f, 0x70, 0xe9,
				0x31, 0x51, 0x6f, 0xe2, 0xac, 0xe7, 0xfc, 0xf2, 0x23, 0xe4,
				0x6d, 0xe3, 0x85, 0xe3, 0xb8, 0x4c, 0x7f, 0xa1, 0x2c, 0x8c,
				0xd7, 0xbb, 0x34, 0x70, 0x12, 0x7b, 0x6c, 0xe7, 0x8b, 0x4d,
				0xb5, 0xdf, 0x52, 0xbb, 0x48, 0x5a, 0x21, 0x81, 0x16, 0x62,
				0xdd, 0x8a, 0xbf, 0xa7, 0xe3, 0x12, 0x02, 0x52, 0x30, 0x6e,
				0x7d, 0x76, 0x52, 0x1d, 0x43, 0x71, 0xf3, 0x6b, 0x1c, 0xa0,
				0xd3, 0xd8, 0x59, 0xb0, 0x2d, 0xb9, 0x66, 0x9a, 0xb5, 0x00,
				0xd9, 0xa6, 0xeb, 0x3f, 0x8a, 0x26, 0x90, 0x98, 0xb3, 0x69,
				0x5f, 0x9f, 0x85, 0x53, 0x28, 0x3c, 0x9e, 0xce, 0x93, 0x7e,
				0xab, 0x17, 0x76, 0x3d, 0x67, 0x0c, 0x4e, 0x21, 0x46, 0x3c,
				0x94, 0x53, 0xba, 0xdc, 0xdf, 0x2a, 0x87, 0x09, 0x24, 0x76,
				0x38, 0x39, 0x2e, 0xc0, 0x58, 0x1f, 0x99, 0x1a, 0xee, 0x9a,
				0xaf, 0xc4, 0xc4, 0x3e, 0xfc, 0xeb, 0x4c, 0xfa, 0x5f, 0x43,
				0x4f, 0x97, 0xe9, 0xac, 0xa9, 0x03, 0x29, 0x0e, 0x64, 0xeb,
				0x24, 0x27, 0x87, 0xe3, 0xf2, 0xc3, 0xc6, 0x5d, 0xde, 0xe5,
				0x3f, 0x46, 0xba, 0xd9, 0x75, 0x31, 0xda, 0x9c, 0xb2, 0xfd,
				0x2b, 0xa5, 0x7e, 0x78, 0x3a, 0xaf, 0x22, 0xc4, 0x80, 0x90,
				0x31, 0xf4, 0xd5, 0x9b, 0x04, 0x19, 0x09, 0xa2, 0x26, 0x91,
				0xd2, 0xfe, 0x44, 0xb6
			};
	}
}
#endif